#!/bin/bash
# TEST SUITE FOR TASK 1 FROM MILESTONE 04
# Set-up: {1,2} middle man, {1,2} postgresql server, {0.1, 0.01} scaling factor, 81 clients
# Purpose: Solve task 1

# CONFIGURATION BEGINS HERE

# the folder where results should be stored (relative to home)
results_folder='worker01'

# MUST BE AT LEAST MIDDLE MEN
machine1='dryad07.inf.ethz.ch'
machine2='dryad08.inf.ethz.ch'

# MUST BE AT LEAST SERVERS
machine3='dryad09.inf.ethz.ch'
machine4='dryad10.inf.ethz.ch'

# DURATION IN MINUTES
duration=10


# AUTOMATIC ITERATION BEGINS HERE
if [ ! -d $results_folder ]; then
	mkdir $results_folder
fi

if [ ! -d /local/group3705 ]; then
	mkdir /local/group3705
fi

C=81
L=100

# 16 worker threads in total, 16 per database
P=1
for M in 7 8 9 6 10 # 16 32 64 81
do
	out_file_path="$results_folder/mm1_ss1_f01_c"$C"_p"$P"_l"$L"_m"$M".raw"
	if [ ! -f $out_file_path ]; then
		middle_man_config="{{middle_man:$machine1};{{P:$P},{L:$L},{M:$M},{db_database:tpch01},{db_host:$machine3}}}"
		args="$C $duration $out_file_path 1 $middle_man_config"
		./client.sh $args
	else
		echo "===========SKIPPING======== $out_file_path"
	fi
done